package basics.day17.BigDecimalDemo;

import java.math.BigDecimal;

public class Test {
    public static void main(String[] args) {
        test_1();
        fun_1();

    }

    public static void test_1() {
        System.out.println(0.09 + 0.01);
        System.out.println(1 - 0.32);
        System.out.println(1.015 * 100);
        System.out.println(1.301 / 100);
        System.out.println("==============");
    }

    public static void fun_1() {
        /*
         * 加
         * */
        BigDecimal b1 = new BigDecimal("0.09");
        BigDecimal b2 = new BigDecimal("0.01");
        BigDecimal BigAdd = b1.add(b2);
        System.out.println("BigAdd：" + BigAdd);
        System.out.println("==============");

        /*
         * 减
         * */
        BigDecimal b3 = new BigDecimal("1");
        BigDecimal b4 = new BigDecimal("0.32");
        BigDecimal BigSub = b3.subtract(b4);
        System.out.println("BigSub：" + BigSub);
        System.out.println("==============");

        /*
         * 乘
         * */
        BigDecimal b5 = new BigDecimal("1.015");
        BigDecimal b6 = new BigDecimal("100");
        BigDecimal BigMul = b5.multiply(b6);
        System.out.println("BigMul：" + BigMul);

        /*
         * 除
         * */
        BigDecimal b7 = new BigDecimal("1.301");
        BigDecimal b8 = new BigDecimal("100");
        BigDecimal BigDiv = b7.divide(b8, 2, BigDecimal.ROUND_HALF_UP);
        System.out.println(BigDiv);

    }
}
